﻿
@{
    ViewData["Title"] = "CreateWireTransfe";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
<script type="text/javascript">
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            , admin = layui.admin
            , table = layui.table
            , upload = layui.upload
            , parentFrameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引;

        /**多语言初始化 */
        top.SetFormPageLanguage(layui);

        $.getJSON("/Console/Roles/GetListJson?userType=1", function (result) {
            let plat = result.data;
            $('#RoleId').append(new Option(top.lang.pleaseSelect, ""));
            plat.forEach(function (v) {
                for (var key in top.lang) {
                    if (top.lang.hasOwnProperty(key)) {
                        if (key === v.remark) {
                            var text = top.lang[key];
                            $('#RoleId').append(new Option(text, v.id));
                        }
                    }
                }
            });
            layui.form.render("select");
        });

        /* 监听提交 */
        form.on('submit(submit-form)', function (data) {

            var type = $("select[name='state']").val();
            if (type == -1) {
                top.AlertByKey(layui, "pleaseSelectStatus", 0);
                return false;
            }
            if ($("#sort").val() == "") {
                top.AlertByKey(layui, "sortPrompt", 0);
                return false;
            }
            if ($("#name").val() == "") {
                top.AlertByKey(layui, "enterNames", 0);
                return false; 
            }
            if ($("#name").val() == "") {
                top.AlertByKey(layui, "enterNames", 0);
                return false;
            }
            if ($("#laverage").val() == "") {
                top.AlertByKey(layui, "pleaseEnterTheLeverageRatio", 0);
                return false;
            }

           /* data.field.State = type;*/
            $.ajax({
                type: "POST",
                url: "/Console/LeverSetting/AddSetting",
                data: data.field, // 你的formid
                async: true,
                error: function (request) {
                    alert("Connection error");
                },
                beforeSend: function (xhr) {
                    layui.layer.load();
                },
                success: function (data) {
                    var item = eval(data);
                    if (item.code == 0) {
                        /**提示语弹框 */
                        top.ShowMessageByKey(layui, "submitSuccess", 6, 1000, function () {
                            parent.layer.close(parentFrameIndex);
                            parent.layui.table.reload("tableReload");
                        });
                    } else {
                        /**提示语弹框 */
                        top.AlertByKey(layui, "submitFail", 0);
                    }
                    layer.closeAll('loading');
                }
            });
            return false;
        });

    });
</script>
<div class="layui-fluid">
    <div class="layui-row ">
        <div class="layui-card">
            <div class="layui-card-body">
                <form class="layui-form" action="" lay-filter="component-form-element">
                    <div class="layui-row layui-col-space12">
                        <div class="layui-col-xs6" style="height: 70px;">
                            <label class="layui-form-label" lay-event="isAvailable">是否启用</label>
                            <div class="layui-input-block">
                                <select name="state" id="state">
                                    <option value="-1" lay-event="pleaseSelect">请选择</option>
                                    <option value="0" lay-event="disable">禁用</option>
                                    <option value="1" lay-event="enable">启用</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-col-xs6" style="height: 70px;">
                            <label class="layui-form-label" lay-event="sort">排序</label>
                            <div class="layui-input-block">
                                <input type="text" name="sort" id="sort" placeholder="sortPrompt" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-xs6" style="height: 70px;">
                            <label class="layui-form-label" lay-event="names">名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="name" id="name"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-xs6" style="height: 70px;">
                            <label class="layui-form-label" lay-event="leverageRatioValue">杠杆比例值</label>
                            <div class="layui-input-block">
                                <input type="text" name="laverage" id="laverage" class="layui-input">
                            </div>
                        </div>                      
                    </div>
                    <div class="layui-form-item layui-layout-admin">
                        <div class="layui-input-block">
                            <div class="layui-footer" style="left: 0;">
                                <button class="layui-btn" lay-submit="" lay-filter="submit-form">立即提交</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
